/**
 * Created by bian on 16-2-24.
 */
var sequelizex = require('../lib/sequelizex');
var shortDataTypes = sequelizex.DataTypes;
module.exports = function (sequelize,DataTypes){
    var shops = sequelize.define('shops',{
        /**
         * 主图*/
        mainImg:shortDataTypes.String(),
        /**
         * 商店名称*/
        title:shortDataTypes.String(),
        /**
         * 电话*/
        phone:shortDataTypes.Phone(),
        /**
         * 营业时间*/
        openTime:shortDataTypes.String(null,true),
        /**
         * 地理位置*/
        location:shortDataTypes.String(null,true),
        /**
         * 物流运送*/
        logistic:shortDataTypes.String(null,true),
        /**
         * 商家优惠消息*/
        message:shortDataTypes.String(null,true),
        /**
         * 状态：
         * 0：待用
         * 1：正常
         * -1：删除*/
        status:shortDataTypes.Int(1),
    },{
        defaultScope: {
            where: {
                status: 1
            }
        },
        timestamps:false,
        associate:function(models){
            models.shops.hasMany(models.Goods);
            models.shops.hasMany(models.GoodsType);
            models.shops.hasMany(models.Adminer);
            models.shops.hasOne(models.Container);
            models.shops.belongsTo(models.Area);
        }
    });
    return shops;
};